package com.emergency.embackend.controller;

import com.emergency.embackend.common.R;
import com.emergency.embackend.entity.SysUser;
import com.emergency.embackend.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sysUser")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @PostMapping("/login")
    public R login(@RequestBody SysUser sysUser){
        String res = sysUserService.login(sysUser.getUsername(), sysUser.getPassword());
        if("输入的验证码有误".equals(res)){
            return R.error(res);
        }
        return R.ok().put("token",res);
    }

}